//
//  UIBarButtonItem+Item.swift
//  开心微博
//
//  Created by 郑开心 on 15/12/6.
//  Copyright © 2015年 郑开心. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    class func barButtonItemWithImage(image: UIImage,highImage: UIImage,target:AnyObject,action: Selector,controlEvents: UIControlEvents) -> UIBarButtonItem {
        let btn = UIButton(type: UIButtonType.Custom)
        btn.setImage(image, forState: UIControlState.Normal)
        btn.setImage(highImage, forState: UIControlState.Highlighted)
        btn.sizeToFit()
        
        btn.addTarget(target, action: action, forControlEvents: controlEvents)
        
        return UIBarButtonItem(customView: btn)
    }
}
